package panel;


import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JPanel;


@SuppressWarnings("serial")
public class ImagePanel extends JPanel {

    private Image image = null;

    public ImagePanel(String filename, int width, int height) {
		image = ToolBag.createResizedCopy(new ImageIcon(filename).getImage(), width, height, true);

        this.setPreferredSize(new Dimension(width, height));
    }

    @Override
    protected void paintComponent(Graphics g) {
        super.paintComponent(g);
        g.drawImage(image, 0, 0, image.getWidth(null), image.getHeight(null), null);
        
    }
    
    
    
    public static void main(String[] a){
    	JFrame frame = new JFrame();
    	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    	frame.add(new ImagePanel("src/images/top.png", 800, 800));
    
    	frame.pack();
    	frame.setVisible(true);
    }
}